{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"https://raw.githubusercontent.com/Qiskit/qiskit-tutorials/master/images/qiskit-heading.png\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"500 px\" align=\"left\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## _*Quantum Teleportation and Superdense Coding*_ \n",
    "\n",
    "\n",
    "The latest version of this notebook is available on https://github.com/qiskit/qiskit-tutorial.\n",
    "\n",
    "***\n",
    "### Contributors\n",
    "Anna Phan, Jay Gambetta, Takashi Imamichi\n",
    "\n",
    "### Qiskit Package Versions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'qiskit': '0.10.3',\n",
       " 'qiskit-terra': '0.8.1',\n",
       " 'qiskit-ignis': '0.1.1',\n",
       " 'qiskit-aer': '0.2.1',\n",
       " 'qiskit-ibmq-provider': '0.2.2',\n",
       " 'qiskit-aqua': '0.5.1'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import qiskit\n",
    "qiskit.__qiskit_version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction\n",
    "\n",
    "In [entanglement](entanglement_introduction.ipynb), we introduced you to the quantum concept of entanglement, in particular, the maximally entangled quantum state $|\\psi\\rangle = (|00\\rangle + |11\\rangle)$. In [testing entanglement](entanglement_testing.ipynb), we explored these types of states in detail, running various experiments to compare quantum mechanics to hidden variable models. In this notebook, we will explore how this state can be used in two quantum communication protocols:\n",
    "* [Teleportation](#teleportation), where a qubit state is transmitted using two classical bits; and\n",
    "* [Superdense Coding](#superdensecoding), where two classical bits are transmitted using one qubit. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:23:57.423948Z",
     "start_time": "2018-09-29T01:23:57.186244Z"
    }
   },
   "outputs": [],
   "source": [
    "# useful additional packages \n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import numpy as np\n",
    "\n",
    "# importing Qiskit\n",
    "from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister\n",
    "from qiskit import BasicAer, IBMQ, execute\n",
    "\n",
    "# import basic plot tools\n",
    "from qiskit.tools.visualization import plot_histogram"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## _Quantum Teleportation_<a id='teleportation'></a>\n",
    "\n",
    "Quantum teleportation is a protocol to transmit quantum states from one location to another, assisted by a previously shared entangled state and a classical communication channel. It was devised by Charles H. Bennett (IBM), Gilles Brassard, Claude Crépeau, Richard Jozsa, Asher Peres, and William K. Wootters in [1993](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.70.1895). It was first demonstrated with photons in [1997](http://www.nature.com/nature/journal/v390/n6660/abs/390575a0.html), and has since been realised in [atoms](http://www.nature.com/nphys/journal/v9/n7/abs/nphys2631.html), [ions](http://www.nature.com/nature/journal/v429/n6993/full/nature02570.html, http://www.nature.com/nature/journal/v429/n6993/full/nature02608.html), [electrons](http://science.sciencemag.org/content/345/6196/532) and [superconducting circuits](http://www.nature.com/nature/journal/v500/n7462/full/nature12422.html). The [record](http://www.nature.com/nature/journal/v489/n7415/full/nature11472.html) distance for quantum teleportation is 143 km via satellite, set in 2012.\n",
    "\n",
    "<img src=\"../images/teleportation.png\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"600 px\" align=\"center\">\n",
    "\n",
    "As illustrated above, the protocol starts out with a shared entangled state between the sender (Alice) and the receiver (Bob):\n",
    "$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt{2}}(|0\\rangle_A \\otimes |0\\rangle_B + |1\\rangle_A \\otimes |1\\rangle_B)$$\n",
    "The first qubit, denoted by subscript $A$, belongs to Alice, and the second qubit, $B$, belongs to Bob.\n",
    "\n",
    "Alice has a quantum state that she wants to convey to Bob:\n",
    "$$|\\psi\\rangle_{C} = \\alpha|0\\rangle_C + \\beta|1\\rangle_C$$\n",
    "\n",
    "At this point, Alice has two quantum states ($C$, the one she wants to teleport, and $A$, one of the entangled pair), and Bob has one quantum state. The total state of the system is given by:\n",
    "$$|\\psi\\rangle_{AB} \\otimes |\\psi\\rangle_C = \\frac{1}{\\sqrt{2}}(|0\\rangle_A \\otimes |0\\rangle_B + |1\\rangle_A \\otimes |1\\rangle_B) \\otimes (\\alpha|0_C\\rangle + \\beta|1_C\\rangle)$$\n",
    "or, in the Bell basis:\n",
    "$$|\\psi\\rangle_{AB} \\otimes |\\psi\\rangle_C = \\frac{1}{2}[\n",
    "|\\Phi^+\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B + \\beta|1\\rangle_B) + \n",
    "|\\Phi^-\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B - \\beta|1\\rangle_B) + \\\\\n",
    "|\\Psi^+\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B + \\beta|1\\rangle_B) + \n",
    "|\\Psi^-\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B - \\beta|1\\rangle_B) ]$$\n",
    "where:\n",
    "$$|0\\rangle \\otimes |0\\rangle = \\frac{1}{\\sqrt{2}}(|\\Phi^+\\rangle + |\\Phi^-\\rangle), \n",
    "|0\\rangle \\otimes |1\\rangle = \\frac{1}{\\sqrt{2}}(|\\Psi^+\\rangle + |\\Psi^-\\rangle)\\\\\n",
    "|1\\rangle \\otimes |0\\rangle = \\frac{1}{\\sqrt{2}}(|\\Psi^+\\rangle - |\\Psi^-\\rangle), \n",
    "|1\\rangle \\otimes |1\\rangle = \\frac{1}{\\sqrt{2}}(|\\Phi^+\\rangle - |\\Phi^-\\rangle).$$\n",
    "\n",
    "Alice now measures her two quantum states, $A$ and $C$, in the Bell basis. This will collapse the three state system into the one of the following four states with equal probability, with the corresponding measurement outcomes:\n",
    "- **00**: $|\\Phi^+\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B + \\beta|1\\rangle_B)$\n",
    "- **01**: $|\\Phi^-\\rangle_{AC}\\otimes(\\alpha|0\\rangle_B - \\beta|1\\rangle_B)$\n",
    "- **10**: $|\\Psi^+\\rangle_{AC}\\otimes(\\alpha|1\\rangle_B + \\beta|0\\rangle_B)$ \n",
    "- **11**: $|\\Psi^-\\rangle_{AC}\\otimes(-\\alpha|1\\rangle_B + \\beta|0\\rangle_B)$\n",
    "\n",
    "Alice now sends the results of her measurements to Bob. Using this information, he performs one of the following transformations on his quantum state to transform it to the desired state $\\alpha|0\\rangle_B - \\beta|1\\rangle_B$:\n",
    "- If he receives **00**, he applies $I = \\begin{pmatrix} 1 & 0 \\\\ 0 & 1 \\end{pmatrix}$\n",
    "- If he receives **01**, he applies $Z = \\begin{pmatrix} 1 & 0 \\\\ 0 & -1 \\end{pmatrix}$\n",
    "- If he receives **10**, he applies $X = \\begin{pmatrix} 0 & 1 \\\\ 1 & 0 \\end{pmatrix}$ \n",
    "- If he receives **11**, he applies $XZ = \\begin{pmatrix} 0 & -1 \\\\ 1 & 0 \\end{pmatrix}$ \n",
    "\n",
    "Transmission (teleportation) of $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$ is thus achieved. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Recall from [entanglement](entanglement_introduction.ipynb) that the steps to make the shared entangled state $|\\psi\\rangle = \\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle + |1_A 1_B\\rangle)$ are:\n",
    "1. Start with an initial state $|0_A 0_B\\rangle$\n",
    "2. Apply $H = \\frac{1}{\\sqrt{2}}\\begin{pmatrix} 1 & 1 \\\\ 1 & -1 \\end{pmatrix}$ on $q_A$ \n",
    "3. Then a $CNOT = \\begin{pmatrix} 1 & 0 & 0 & 0\\\\ 0 & 0 & 0 & 1\\\\0& 0& 1 & 0\\\\0 & 1 & 0 & 0 \\end{pmatrix}$ from $q_A$ to $q_B$\n",
    "\n",
    "With $q_A = q_1$ and $q_B = q_2$, this looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:49.119614Z",
     "start_time": "2018-09-29T01:25:49.111487Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.cx.CnotGate at 0x12503b6a0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Creating registers\n",
    "tq = QuantumRegister(3)\n",
    "tc0 = ClassicalRegister(1)\n",
    "tc1 = ClassicalRegister(1)\n",
    "tc2 = ClassicalRegister(1)\n",
    "\n",
    "# Quantum circuit to make the shared entangled state \n",
    "teleport = QuantumCircuit(tq, tc0,tc1,tc2)\n",
    "teleport.h(tq[1])\n",
    "teleport.cx(tq[1], tq[2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alice then prepares her quantum state to be teleported, $|\\psi\\rangle_{C} = \\alpha|0\\rangle_C + \\beta|1\\rangle_C$. In this experiment, $\\alpha = \\cos(\\frac{\\theta}{2})$ and $\\beta = \\sin(\\frac{\\theta}{2})$ where $\\theta = \\frac{\\pi}{4}$. This state can be created by applying a rotation around the y axis:\n",
    "$R_y(\\theta)$ on $q_C$\n",
    "\n",
    "With $q_C = q_0$, this looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:49.690746Z",
     "start_time": "2018-09-29T01:25:49.684872Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.ry.RYGate at 0x12434cfd0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.ry(np.pi/4,tq[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alice now applies $CNOT$ to her two quantum states $q_A(q_1)$ and $q_C(q_0)$, followed by an $H$, to entangle them and project them into the Bell basis:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:50.340964Z",
     "start_time": "2018-09-29T01:25:50.335022Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.barrier.Barrier at 0x10e571f60>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.cx(tq[0], tq[1])\n",
    "teleport.h(tq[0])\n",
    "teleport.barrier()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "She now measures her two quantum states $q_A(q_1)$ and $q_C(q_0)$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:50.803157Z",
     "start_time": "2018-09-29T01:25:50.794385Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.circuit.measure.Measure at 0x12503b710>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.measure(tq[0], tc0[0])\n",
    "teleport.measure(tq[1], tc1[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Depending on the results of these measurements, Bob has to apply an $X$ or $Z$, or both, to his quantum state $q_B(q_2)$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:51.189309Z",
     "start_time": "2018-09-29T01:25:51.182122Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.x.XGate at 0x12503b0b8>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.z(tq[2]).c_if(tc0, 1)\n",
    "teleport.x(tq[2]).c_if(tc1, 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "His state is now the same as the state Alice prepared earlier, which can be verified by measurement:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:51.759153Z",
     "start_time": "2018-09-29T01:25:51.752995Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.circuit.measure.Measure at 0x12503b048>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.measure(tq[2], tc2[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:53.317500Z",
     "start_time": "2018-09-29T01:25:51.914340Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAuUAAAEsCAYAAABkNc0fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3de3zO9eP/8ee1kYWdMIoZUWhOO7SEmDTGFzmsfCuRHKboQEtbKkqfNBLpRPtI1KgcEpXw4WNLDmvsszmU7yc5+5TDuMzkUNv1+6OffbbMDnZd12vb9bjfbm63y/t6v9+vp8tlnnvv9X5dFpvNZhMAAAAAY9xMBwAAAABcHaUcAAAAMIxSDgAAABhGKQcAAAAMo5QDAAAAhlHKAQAAAMMo5QAAAIBhlHIAAADAMEo5AAAAYBilHAAAADCMUg4AAAAYRikHAAAADKOUAwAAAIZRygEAAADDKOUAAACAYZRyAAAAwDBKOQAAAGAYpRwAAAAwjFIOAAAAGFbFdAAAcJY9e/YUu88777yjxx9/vMh9WrRoYa9IAABI4ko5ABTw7rvvmo4AAHBBlHIAAADAMEo5AAAAYBilHADyWbp0qekIAAAXRCkHAAAADKOUA0A+9957r+kIAAAXxJKILm7s2LFKT093+rhBQUF68803nT4uSsfU+0PiPWJP/DsHgPKPK+UuLj093en/WZsYE9fG1N8V7xH74t85AJR/XCmHgoKClJSU5LTxunTp4rSxUHbOfn9IZt8jY8aMMTa2I/HvHADKN66UA0A+xX2aJwAAjkApB4B8OnfubDoCAMAFUcoBIJ8TJ06YjgAAcEGUcpRI/fr1df3116tmzZry9vZWjx49dPjwYdOxAAAAKgVKOYp19OhR/fLLL0pLS1N2drb27dun48ePKzY21nQ0wO4CAwNNRwAAuCBKOYqVmpoqLy8vtWjRQpJUu3ZthYSE6Pjx44aTAfa3bNky0xEqpEuXLslms5mOAQAVFqUcxUpNTVVYWJgsFov++OMPrV69Wp999pkefPBB09EAu5s4caLpCEadOHFCs2fP1iOPPKKwsDC1bNlSt912m4YMGaK33npLv/zyyxXH/Pbbb+rRo4defPFFA4kBoHJwmVI+f/78Uq+bGxoaqjVr1jgmUAWSmpqq7777Tj4+PvLw8NDAgQP1wQcfaNiwYaajVXqXLl3S2rVr9cknn2jDhg3KyckxHanSW7JkiekIRvz6668aOnSo/P39NXr0aK1atUq+vr4KDAyUn5+f1q1bp6eeekoBAQG6//77dejQIUl/FvLevXsrOTk576dpAIDSM1rKc3JyNH78ePn5+cnT01NRUVE6efJkuRm7b9++WrlypVPylGfbtm3TJ598IqvVqsOHD8vf31979uwxHatSs9lseuutt+Tv76/IyEg9+OCD6tq1qxo3bqyPPvrIdLwi1a9fX3Pnzi2wzWazycvLS8uXLzeUCkVZtmyZAgMD9emnn2rkyJHauXOnfv31V61du1ZLlizRN998o//85z/6v//7Pz355JP66quv1KpVKyUkJOQV8gULFuihhx4y/UcBgArLaCmPj4/XihUrlJKSoiNHjkiSBg8eXG7GppRLe/fu1enTpxUSEiJJuvHGGxUTE6M5c+YoNzdXkrRp06YCr92gQYP0/fffG8lbWUycOFFPPfXUFcvzHT16VA8//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iKUkZGhp556Si+88EKZ8syfP1/z589XUlKSDh8+XOzYl61du1bPPfecw68+/nU9amcKDw9XUlJSifbt3r27kpKS5OXlVWB7dna2nnvuOU2aNKnYc3Tp0oWrkTBi3Lhxxe4zc+bMYvebOXOmvSKhEvrr19TbbrtN58+f186dO4v8yV1++Qv55Tnkv/32m/z9/RUREaHFixfn7cvXVKDiKKp2O2yd8uTkZOXm5uYVcum/H18dHBycd6X1zJkzBY6zWq15hW/+/Plat25d3pxve/H09Cx27MsOHjyogIAAu45fGFM3G5Z2RZpt27bppZde0pAhQwpsb926damulJfmG4FrlZWVpbp16+rixYtF7nfdddfp+PHj8vb2dmiev3rqqac0b948nTlzptj/qC0WS7HvkTNnzsjHx0dTpkzRc889Z8+olcaePXuK3WfmzJmKjo4ucp8ZM2bYK1K5Fjc1QfGx0Vc8xtX99Wvqjh07tH37dr3zzjtlKuTSn0ugPvLII3rrrbd06tQp1apVK+8YZ3xNBeBYDpu+cvz4cdWtW7fAtkWLFqlevXq64YYb5OPjo4CAAKWlpeU9v2/fPmVlZeVNRfH393dItpKMfdnKlSvVt29fh+SoaPbu3avTp08rMjJS/v7+eb8uXLggq9WqsLAw0xEL8PLy0gMPPFDsnPIHHnjA6YVckoKCgpSdnW236Sbp6el55wVQPmzZskWS9D//8z8l2v9qhfyynj176o8//uDeEaASclgpDwwM1N69e5WcnKxLly5p0aJFio+PV3BwcN4+0dHRmjp1qvbv36+srCzFxsYqMjJSjRs3dlSsUo197tw5bdiwQb1793Z4noogNTVV1atXv2JO5ObNm9WwYcMrvgkrDyZOnChfX99Ci7mbm5t8fHyMfVhMhw4dJElfffWVXc739ddfy93dvdx9c1TRvPzyy6YjoBLJyMiQj49Pif5fK66QS1JISIik/34TDqDycFgpDwsL0/PPP68BAwbI399fKSkpateuXYFSHhcXpz59+igsLEwNGjRQTk6OEhMTSz3WlClT1LJly1IdU5Kx165dq+DgYNWpU6fUmSqj1NRUhYWFqUqVgrOetmzZUu5u8rzspptu0qZNmwrc1HtZaGioNm3apCZNmhhIJjVv3lwdO3bU7NmzlZOTU6Zz/fbbb3lrnvN+LZuBAweajoBK5JZbblFUVFSx9w199tlnJVqHvFatWurVq5caNGjgiLgADHLYnHJJmjx5siZPnpz3+8aNG2vkyJF5v3d3d9f06dPL/MlkEyZM0IQJE0p1TEnGZupKQVebRzt79mwnJymd5s2b6/vvv1daWpq2bNmixx9/XNu2bSu0qDvb008/raioKM2cOVPPPPPMNZ9n4sSJOnXqVIluZETRbr31Vv3444+mY6CSKOm/yZ49e+rFF1/Uiy++WOw65Pb66RqA8sVpHx6UlZWlgwcPFrhSXpxhw4bp9ddf1/z589WnTx8Hpitco0aN8tZUR8UXEhKiMWPGSFK5KOSS1L9/f/Xr108vvPCCvv/++2s6x5o1azRjxgw9+uij6tixo50TAnAGLy8vTZ48mQ8GAlyYQ6+U57dr1y55enqqadOmJT5m3rx5dhs/KChIQ4cOLdUxL730kt3GBwpjsVg0Z84cdejQQZGRkfriiy8UHh5e4uNXrFih+++/X23bttW0adMcmBQAADiS066UX/40MlPrcV9LKQecoV69evrnP/8pPz8/3XXXXYqJidHp06eLPObYsWMaPny4+vXrp5YtW2rt2rV5S32ibEq7TCgAAPbgtCvlAK6uUaNG2r59u5599lnNmDFDs2fP1sCBAxUeHp632k1qaqrS09O1fv16ff7558rJyVFcXJwmTZp0xSes4tqV93skAACVE6UcKCc8PT01e/ZsPfroo3rvvff06aefasGCBXnP33777ZKk2rVra8yYMXr00UfVvHlzU3Errccee4xiDgBwOko5UM60bdtW77//vmbPnq1///vf+uGHHxQVFaXly5erdevWatKkibFpYK6AT0UEAJhAKQfKKTc3N7Vo0UItWrSQzWYzHQcAADiQ0270BAAAAFA4rpRD6enpTl1xIj09XUFBQU4bDygNPjgIZcXXVADXgivlLi4oKMjpX8xNjAmU1OLFi01HQAV2rV/f9h36pdDHjhwTQPnClXIX9+abb5qOAJQrkyZN0sCBA03HQAV1rV9T46YmKD42+orHAFwHV8oBAAAAwyjlAAAAgGGUcgDI57333jMdAQDggijlAJBPy5YtTUcAALggSjkA5BMeHm46AgDABVHKAQAAAMMo5QCQT1hYmOkIAAAXRCkHgHxSU1NNRwAAuCBKOQAAAGAYpRwAAAAwjFIOAPksXbrUdAQAgAuilAMAAACGUcoBIJ97773XdAQAgAuqYjoAAAConMaOHav09HSnjxsUFKQ333zzmo41lVkqW25H4fVwHq6UAwAAh0hPT3d6oSvrmCYymxy3OLwezsOVcgDIZ8yYMaYjAJVKUFCQkpKSnDZely5dynwOZ2eW7JPbUXg9nIMr5QCQz+OPP246AgDABVHK4RKsVqs2bNigRYsWSZL++c9/ymq1Gk6F8qhz586mIwAAXBDTV1BpnT9/Xp988olmz56tbdu2FXju7rvvliSFhobqscce04MPPqjrr7/eREyUMydOnDAdAQDggrhSjkrp22+/VevWrTV8+HCdP39er7zyilavXq09e/ZIklavXq2//e1vunjxokaMGKFWrVopOTnZcGoAAOCqKOWodN58802Fh4fLZrNpzZo12rlzp1544QVFRkaqefPmkqTIyEg9//zz2rFjh9auXSvpz5tKZsyYYTI6yoHAwEDTEQAALohSjkpl9uzZGjdunAYMGKAdO3aoe/fuslgsV93fYrGoW7du2rFjh+69917FxMTo3XffdWJilDfLli0zHQEAXA73eVHKUYns2rVLY8eOVa9evfTZZ5+pRo0aJT62Ro0a+uSTT9S7d2+NGzdOu3btcmBSlGcTJ040HQEAKqTc3Fz94x//0OOPP6727dvLz89PtWrVUtOmTRUVFaUZM2YUet/O5s2bddNNN2nFihUGUpcfLlPK58+fX+o1L0NDQ7VmzRrHBIJd2Ww2RUdHy8vLSx9++KGqVCn9PcxVqlTRvHnz5OPjoxEjRshmszkgKcq7JUuWmI4AABXOF198oRYtWqh79+5asGCBrrvuOg0YMECDBg1SaGioMjIyFBMTI39/f40cOVKnT5+W9Gch79Gjh/z8/HTbbbcZ/lOYZbSU5+TkaPz48fLz85Onp6eioqJ08uTJcjN23759tXLlSqfkQdmkpKRoy5Ytevnll+Xn53fN5/Hz89PkyZOVkpKirVu32jEhAKA4H374oWrWrHnFL3d3d7m7uys7O9t0xCtkZ2fLz89PS5cuzdt2/vx5dejQQffee69yc3MNpnO88+fPa/Dgwerfv788PDyUmJiokydPKjk5We+//77efvttLV68WHv37tXu3bs1YsQIffjhh2rZsqXefvtt9ejRQzfccIM2bNigBg0amP7jGGW0lMfHx2vFihVKSUnRkSNHJEmDBw8uN2NTyiuODz74QJ6ennZ5/zz00EPy9PTUBx98YIdkAICSeuSRR5SdnV3g17x581S1alXNnTtXNWvWNB3xCjVr1tQzzzyjyZMny2azKScnRwMHDlS1atW0cOFCublV3kkJ58+fV69evbRw4UK99NJL2r59uwYNGqRq1aoVun9gYKDeffddff/997ruuuv05JNPysvLi0L+/zn8nbJ48TMipdcAABxDSURBVGLdfPPNqlmzprp3766YmBjdd999kqSEhATFxsaqSZMm8vb21rRp07R69WodPHjQ0bFKNHbbtm3l7u6u7du3OzwPymbz5s3q3LmzPD09y3yumjVrKjw8XJs3b7ZDMlQ0LI0JlB8ff/yxhgwZonnz5umRRx4xHeeqHn/8cf36669atmyZoqOjdeTIEa1YseKq5bSyGDNmjJKSkvTxxx9r0qRJqlq1aomOu3DhgjIzM1WtWjVlZmbqwoULDk5aMTi0lC9YsEAxMTFauHChzp49q969e2vWrFkKDg6W1WrVoUOHFBoamrd/06ZN5eXlpYyMjFKNEx8frzZt2pR4/9KM3bdvX5e/8aC8u3Dhgvbs2aOQkBC7nTM0NFR79uzR+fPn7XZOVAy7d+82HQGApL///e8aOXKkFi5cqAcffNB0nCLVqFFD48eP19ChQ5WUlKTVq1fLy8vLdCyH+uabb/Thhx8qLi5OgwYNKvFxl+eQ33jjjdq4caOuu+46DRs2rNJP8ykJh5Xy3377TU8//bQSEhLUrl07WSwWjRgxQjk5OQoODtbZs2clSd7e3gWO8/HxUVZWln7++Wd17txZnTp10p133nnFJzLmFxcXpx07dpQ4W3Fj59erVy99/fXXJT43nC87O1u5ubllmkv+V35+frLZbHnvFbiO0aNHm44AuLy3335bTz75pJYs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ae3atQoODladOnVKdW44X//+/bVnzx67rC2ekpKiH374Qf3797dDMlQ013J1C0DZpKen67XXXtNvv/2m7t27X7FO+XPPPWc64hV27dql3r17a8aMGerXr1/e9jFjxujEiROV+oPIDhw4oGbNmhW7X0kKuaS8cx04cMCeMSsch01fkf78MdTkyZPzft+4cWONHDky7/fu7u6aPn26pk+fXujxTzzxhG6++WY99thjRY4zYcIETZgwoVTZihtb+nPqSt++fUt1XpgxaNAgPfvss3rllVf09ddfX/MVbpvNpldeeUWenp6lupsclcett96qH3/80XQMwKUEBQVVuGmcrVq10qlTp67YXr16dR07dsxAIuf5+uuvS/TJ2Zs3by7RBwO1bNlSP/74o/z9/e0Zs8Jx2or2WVlZOnjwYIEr5UVJSkpSQkKC1q9fry5dumjAgAEOTnilRo0a5a2pjvKtZs2amjx5sr755hstWLDgms/z0UcfadWqVZo8ebJd1jwHAKCyady4cYkK9DPPPKO0tLRiPxjIw8NDLVq0KJcfDuVMDr1Snt+uXbvk6emppk2blmj/Ll266NKlS3YbPygoSEOHDi3VMS+99JLdxofjPfHEE1q+fLkeffRRNWjQQN26dSvV8evWrdOoUaPUqVMnPfHEEw5KCQCA63D1ol0aTrtS3qFDB2VlZRm7ce5aSjkqFjc3Ny1btkzNmzdXr169NHXqVP3xxx/FHpeTk6Np06apV69eatasmZYvX27X1X5QsVSUG8wAAJWL00o54Ay1a9dWUlKS+vTpo7i4OIWEhGju3LmFfgjQ2bNnNW/ePIWEhCg2Nla9evVSUlJSgeU44Xpmz55tOgIAwAVRylHp+Pr6aunSpfrss89ks9k0cuRIeXt7KzAwUL169ZL0500l3t7eGj58uHJycvTpp59q2bJlqlWrluH0MK24G8sBAHAEp80pB5zJYrFo4MCBuu+++7Rp0yatX79e27dv1y+//CJJatq0qQYOHKi7775bHTt2ZD1y5HGlD6oAAJQflHJUahaLRXfeeafuvPNO01EAAACuiukrAAAAgGFcKQeAfPjgIMC+0tPTnbqqUXp6uoKCgsp8DmevxGSP3I7C6+EcXCkHg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QAAAMMo5QAAAIBhlHIAAADAMEo5AAAAYBilHAAAADCMUg4AAAAYRikHAAAADKOUAwAAAIZRygEAAADDKOUAAACAYZRyAAAAwDBKOQAAAGDY/wNbelBnuH52vQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 963.2x379.26 with 1 Axes>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "teleport.draw(output='mpl')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's now create and execute the quantum circuits and plot the results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:53.362137Z",
     "start_time": "2018-09-29T01:25:53.325011Z"
    }
   },
   "outputs": [],
   "source": [
    "local_backend = BasicAer.get_backend('qasm_simulator') # note that this circuit can not be run on an IBM Q device\n",
    "teleport_job = execute(teleport, local_backend) \n",
    "teleport_result = teleport_job.result()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We must manipulate the data to understand the results better, first only plotting the results of Alice's measurement:  \n",
    "\n",
    "Note each classical register is seperated by a space, and the order is c2 c1 c0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:53.600182Z",
     "start_time": "2018-09-29T01:25:53.364736Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAE6CAYAAAB00gm8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3df5xWdZ338ddHEAUFE2UJUlSSEJJw1C01QM00w0pX2SwtrN3W/JFp7K5t3qnppu2t2ertapm35q+l1KS2/LF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tBD179uSSSy5hwoQJNDU1ceKJJzJixAguvvhiGhoa+PjHP87555/PypUr+eIXvwjALrvswuTJk+nRowcXXnghxxxzDJnJPvvsw8SJE1v2PWXKFM4888zOOjRJ6tIiMzu7hk7T0NCQU6dO7ewyJEl1pH///o9k5v5trfPyrCRJJRmakiSVZGhKkqqyOdOA7rzzzi3TfZ5wwgkty08//XT22WeflnWzZs2qybFUy45AkqTSNnca0N69ezNt2rQ2933BBRdw9NFH1+Q4NpVnmpKk0jZnGtCuwNCUJJW2OdOAArz11lt85CMf4fDDD+euu+5aZ9uLLrqIMWPGcM4557Bq1ar2L74deHlWktQhmqcBvfPOO1uWzZw5k8GDBzNv3jyOPvpoRo4cyR577MG5557LwIEDaWxs5Gtf+xpXXHEFZ599didW3zbPNCVJpW3ONKBQnJkC7L777owZM6ZlGtB3v/vdRATbbLMNJ5xwAtOnT+/gI9k0hqYkqbTNmQb0tddea7nsunTpUh566KGWaUBfeOEFADKTu+66ixEjRtToiKrj5VlJUmmbMw3onDlzmDRpEltttRVr167lzDPPbOl1++Uvf5klS5aQmYwaNYrLLrusMw9zg5xGz2n0pLp2//33c84559DU1MTnP/95zjrrrHXWX3XVVdx888307NmTnXfemSuvvJJdd921Zf3y5cs58MADOeqoo7jkkksA+OQnP8mLL77Y8mCDO+64Y50zInVvG5tGzzNNSXVrc8cEAlx88cUcdNBBb9v3NddcQ0NDQ02OQ12HodkOzr5xx84uod1cctKrnV2C1KL1mECgZUxg69AcO3Zsy+v999+f2267reX9o48+yssvv8xhhx3Go48+WrO61XXZEUhS3dqcMYFr167l3HPP5cILL2xz26985SuMGzeOSy+9lO58m0rV8UxTUpew/pjA6667jsMPP3yd0G12zTXXMHjwYFasWMFJJ53Erbfeymc+85lal6wtkKEpqW5VOybwzjvvbBkT+Ic//IEHH3yQ6667jpUrV9LY2Mh2223H+eef3zJWsG/fvkyYMIHp06cbmirF0JRUt1qPCRw0aBBTpkzhhz/84TrbNI8JvP3229fpAdt6u8mTJ/Poo49y/vnns2bNGpYtW8ZOO+3E6tWruffeeznkkENqdUjawhmakurW5owJ3JBVq1YxYcIEVq9eTVNTEwcffDATJ06s1SFpC+c4zXYYp2nvWUnqOjY2TtPes5IklWRoSpJUkqEpVdx///188IMfZL/99uPyyy9/2/qrrrqKAw44gDFjxnDMMcfw3HPPAfDcc89xyCGHMG7cOA488EB+9KMftXxmwoQJjB07lgMPPJBJkybR1NRUs+OR1P7sCCSxedO1DRw4kHvvvZdtttmG119/nQ9/+MMceeSRDBo0iOuvv55+/fqRmZx00kn8/Oc/57jjjuvEI5XWZZ+M6nimKbHudG29evVqma6ttbFjx9KnTx+gmK5t0aJFAPTq1atlbGBjYyNr165t+Uy/fv0AWLNmDatXryYianE4kjqIoSmxedO1ASxcuJAxY8YwatQozjzzzHUG4B933HG8733vY/vtt+foo4/umAOQVBOGplSl5unazjjjjJZlu+yyCw888AB//OMf+clPfsJLL73Usu6OO+5g9uzZrFq1imnTpnVGyZLaiaEpUf10bZMnT265JLv+fvbaay8efPDBdZZvu+22jB8//m2XfCVtWQxNiXWna2tsbGTKlCkceeSR62zTPF3b5MmT15mu7fnnn+fNN98E4LXXXuOhhx5i2LBhvP7667zwwgtAcU/zvvvuY9iwYbU7KEntzt6zEps3XdtTTz3FueeeS0SQmZx++umMHDmSl156iRNPPJFVq1axdu1axo4d2/JZSVsmp9FzGr11OI2e1L348+vtNjaNnmeakmrGH9Da0tX8nmZEnBYRz0bEWxHxSESM3ci2x0bEfRHxckSsiIiHIuJTG9n+sxGREXFnx1QvSerOahqaEXE8cAVwMdAA/A64JyKGbOAjBwNTgaMq298N/KytoI2IocClwG86oHRJkmp+pjkJuCEzr83M2Zl5BrAYOLWtjTPzzMz8l8x8ODOfycwLgEeAY1pvFxFbAz8G/hcwt2MPQZLUXdXsnmZE9AL2A7673qr7gIOq2FVfYP2bCRcB8zLzxog49B3qOBk4GYoxddOnTweKGWD69OnDM888A8AOO+zA0KFDmTFjBgA9evRg9OjRzJkzh5UrVwIwY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9XZnbRqk0nASxTPcl0M3A5MycyVlR8Kf0fRa/bOTiu2m6v8ovkFintl+wArKO79/wH4TmZucZcCt2Qb6q0cEX2A6cCPMnOLu51haNaRiLgBeD/wS+AVikuzo4D3UfzA/qbf+LW1gTZpAPaiGNpwaWbe12kFdmMR0Q9Y0foHc+XMc1tge2BviisDfs/USFtt0sY221J0FPpx5ZnIWxRDs05UzlZWUFyymNZq2RDgQxT3AYYCn87M6Z1WaDeykTbZBTiA4uxyN4rnu9omNRYR11D00HyYYjzg28bGRsSOmfmqYzRro2SbvCszX6t5ce3E3rP1YyTwLMVwE6C4/p+Z8zPzNuCTFJdq/7qT6uuONtQmz2Xm7RT3ylZgm9RcRHyW4peWy4D/oBjOcGxE7Fm5n0ZEbA/8KCJGGZgdbwNt8lcR8d5WbdIbuLF5ON2WyDPNOlH5z3QnxcQFE4E/rz9FXkScAfxtZu7TCSV2O7ZJ/YqIa4Em4BLgWOAk4L3AHOBu4FcUEx5ckZm9OqvO7qS7tIlnmnWiMqfp/wJ6AzcBEyNi18pvy803zw+mGJOmGrBN6lNlbOazwGuZOTczv5uZo4C/pJg27ySKYVpX4qQGNdGd2sQzzTpTuWxxLvApionaHwRepph7djHwpcyc1XkVdj+2Sf2pzAU8sDKnbC9g9Xodgo6nmNJw38x8tLPq7E66S5sYmnWqMtThKOAYim7zjwO3Z+aTnVpYN2ab1LdKz9nIzKaI+DuKy4B9Oruu7qwrtomhuQUIHwFWd2yT+hYRk4AemXlpZ9eiQldpE0NTUpdTeXJGk7/Y1I+u0iaGpiRJJdl7VpKkkgxNSZJKMjQlSSrJ0JQkqSRDU5KkkgxNSZJK+v8/LYdkiLhUqwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = teleport_result.get_counts(teleport)\n",
    "alice = {}\n",
    "alice['00'] = data['0 0 0'] + data['1 0 0']\n",
    "alice['10'] = data['0 1 0'] + data['1 1 0']\n",
    "alice['01'] = data['0 0 1'] + data['1 0 1']\n",
    "alice['11'] = data['0 1 1'] + data['1 1 1']\n",
    "plot_histogram(alice)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As expected, the probabilities are roughly equal.  \n",
    "\n",
    "Now, manipulate the data to plot the result of Bob's measurement:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:53.945920Z",
     "start_time": "2018-09-29T01:25:53.606228Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAEyCAYAAACYgYvRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAfqElEQVR4nO3df5jWdZ3v8edbBAICZZCFGWlAhEPjwOKouemW6Ck2+3G8yLyiLstatzzW9sM4m+U5ldkP20hbPf3Otcvsx54sad1KNzJcbcXNAiR+OYuOwCIjjUDAAgJO7/PHfeOO4zB8b5gfN8zzcV33Nff38/18P/P+cl/3vPj+jsxEkiQd2nH9XYAkSUcLQ1OSpIIMTUmSCjI0JUkqyNCUJKkgQ1OSpIKO7+8C+tOYMWOyvr6+v8uQJFWRRx555OnMHNvVvAEdmvX19SxatKi/y5AkVZGampr1B5vn7llJkgoyNCVJKqhPQzMizouIf4qIJyMiI+KdBZaZERH3R8Se8nKfiIjo1OdNEbE6IvaWf76x11ZCkjRg9fWW5ouBlcAHgT2H6hwRo4BfAJuBl5WX+zAwr0Ofc4AfAN8DTi///GFE/FlPFy9JGtj69ESgzLwbuBsgIm4rsMilwHDgHZm5B1gZES8F5kXEF7N0t/mrgPsy87PlZT4bEReU29/a0+sgSRq4qv2Y5jnAr8qBecDPgT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aw1Z8h+Z+UPgDZRCdW4/1Sepk4h4K6X/0N4I3AV8ISLeGBGnRsSwcp9hwK0RMaMfSz2quaWpFyh/sX4KDAcuAx7PzD926vN+4K8y8/R+KFFSJxFxC6UHWMwHLgbeAZwKNAN3A78EpgE3Z+aQ/qrzaOeWpl4gM/cA/wcYBtwOXBYRL4mIFwNExHBgFqVbFkrqZxFxPKW9Q3/IzJbMvCEzZwAvA+6nFKB3AF8CvtN/lR793NLUQUXEdODjwEXALkpPnWkDXk3pTNp3ZeaK/qtQ0gERMRoYl5mPRsQQYH/HE4IiYi7wD8AZnotw+AxNHVL58pPXA3OAZyhtYf4wMx/t18IkdSsijqP0d749It5Nadfs8P6u62hmaKoiEXFc5+ObkqpfRMwDBmXmF/q7lqOZoSlJA0BEDAba/U/vkTE0JUkqyLNnJUkqyNCUJKkgQ1OSpIIMTUmSCjI0JUkqyNCUJKmg/w9dlo5seFX5ywAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bob = {}\n",
    "bob['0'] = data['0 0 0'] + data['0 1 0'] +  data['0 0 1'] + data['0 1 1']\n",
    "bob['1'] = data['1 0 0'] + data['1 1 0'] +  data['1 0 1'] + data['1 1 1']\n",
    "plot_histogram(bob)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As expected, $|\\alpha|^2 = |\\cos(\\frac{\\pi}{8})|^2 \\approx 0.854$ (the probability of measuring 0) and $|\\beta|^2 = |\\sin(\\frac{\\pi}{8})|^2 \\approx 0.146$ (the probability of measuring 1). Why don't you try teleporting a different quantum state now?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## _Quantum Superdense Coding_<a id='superdensecoding'></a>\n",
    "\n",
    "Quantum superdense coding is the dual protocol of quantum teleportation, whereby two classical bits of information are transmitted using only one qubit and a previously shared entangled state. It was devised by Charles Bennett (IBM) and Stephen Wiesner in [1992](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.69.2881). \n",
    "\n",
    "<img src=\"../images/superdensecoding.png\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"600 px\" align=\"center\">\n",
    "\n",
    "As illustrated above, and as in quantum teleportation, the protocol starts out with a shared entangled state between the sender (Alice) and the receiver (Bob):\n",
    "$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt{2}}(|0\\rangle_A \\otimes |0\\rangle_B + |1\\rangle_A \\otimes |1\\rangle_B)$$\n",
    "The first qubit, denoted by subscript $A$, belongs to Alice, and the second qubit, $B$, belongs to Bob.\n",
    "\n",
    "Alice wants to send a two bit message to Bob, 00, 01, 10, or 11.  She performs a single qubit operation on her qubit which transforms the entangled state according to which message she wants to send:\n",
    "- For a message of **00**: Alice applies $I = \\begin{pmatrix} 1 & 0 \\\\ 0 & 1 \\end{pmatrix}$. The resultant state would be $|\\psi_{00}\\rangle = \\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle + |1_A 1_B\\rangle)$\n",
    "- For a message of **01**: Alice applies $X = \\begin{pmatrix} 0 & 1 \\\\ 1 & 0 \\end{pmatrix}$. The resultant state would be $|\\psi_{01}\\rangle = \\frac{1}{\\sqrt{2}}(|1_A 0_B\\rangle + |0_A 1_B\\rangle)$  \n",
    "- For a message of **10**: Alice applies $Z = \\begin{pmatrix} 1 & 0 \\\\ 0 & -1 \\end{pmatrix}$. The resultant state would be $|\\psi_{10}\\rangle = \\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle - |1_A 1_B\\rangle)$ \n",
    "- For a message of **11**: Alice applies $XZ = \\begin{pmatrix} 0 & -1 \\\\ 1 & 0 \\end{pmatrix}$. The resultant state would be $|\\psi_{11}\\rangle = \\frac{1}{\\sqrt{2}}(- |1_A 0_B\\rangle + |0_A 1_B\\rangle $\n",
    "\n",
    "The key to superdense coding is that these four states, $|\\psi_{00}\\rangle, |\\psi_{01}\\rangle, |\\psi_{10}\\rangle, |\\psi_{11}\\rangle$ (otherwise known as the [Bell states](https://en.wikipedia.org/wiki/Bell_state)), are orthonormal and are hence distinguishable by a quantum measurement."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:53.953827Z",
     "start_time": "2018-09-29T01:25:53.947814Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.cx.CnotGate at 0x125680128>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Creating registers\n",
    "sdq = QuantumRegister(2)\n",
    "sdc = ClassicalRegister(2)\n",
    "\n",
    "# Quantum circuit to make the shared entangled state \n",
    "superdense = QuantumCircuit(sdq, sdc)\n",
    "superdense.h(sdq[0])\n",
    "superdense.cx(sdq[0], sdq[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alice now needs to decide what two bit message she wants to transmit to Bob, ($00$, $01$, $10$, or $11$), and perform the corresponding to transformation ($I$, $X$, $Z$ or $XZ$ respectively) to her qubit $q_A$ ($q_0$). In this case, she encodes $11$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:54.598839Z",
     "start_time": "2018-09-29T01:25:54.591683Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.extensions.standard.barrier.Barrier at 0x125544518>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# For 00, do nothing\n",
    "\n",
    "# For 01, apply $X$\n",
    "#shared.x(q[0])\n",
    "\n",
    "# For 01, apply $Z$\n",
    "#shared.z(q[0])\n",
    "\n",
    "# For 11, apply $XZ$\n",
    "superdense.z(sdq[0]) \n",
    "superdense.x(sdq[0])\n",
    "superdense.barrier()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Bob now needs to 'decode' the message that Alice sent him. Since measurement in Qiskit is only possible in the standard computational basis, he does this by:\n",
    "1. Applying a $CNOT$ from $q_A$ to $q_B$\n",
    "2. Then a $H$ on $q_A$ \n",
    "3. And measuring $q_A$ and $q_B$\n",
    "\n",
    "Recalling that $q_A = q_0$ and $q_B = q_1$, this looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:55.121279Z",
     "start_time": "2018-09-29T01:25:55.113311Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.circuit.measure.Measure at 0x12568b198>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "superdense.cx(sdq[0], sdq[1])\n",
    "superdense.h(sdq[0])\n",
    "superdense.measure(sdq[0], sdc[0])\n",
    "superdense.measure(sdq[1], sdc[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:56.638472Z",
     "start_time": "2018-09-29T01:25:55.342841Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAl0AAADRCAYAAAD2bwehAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deVwTd/4/8FfAAyoEKKLWAxGsoiiCFG0rFjwKZRWpFVG8qlbTitabhaqtFK2Cty1qxYuuiNZz8apatkrXi7VScPHqz0U51lpBDVEsUkN+f/g1S8oVMJlJwuv5ePgQJ5/J580wjK98ZuYzEpVKpQIRERER6ZWZ2AUQERERNQQMXUREREQCYOgiIiIiEgBDFxEREZEA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dIpVJkZWXVuX8iIhKWjXUz+PX2UP97wJs9YdXMUsSKiDQJHrpKSkrw4YcfIiEhAcOGDYOFhQWsra0REBCgbjNq1CgUFxfj119/RXR0NLp3765+beDAgXBwcMDixYtr7CcqKgqXLl3Suq6HDx8CgHqU7TlbW1soFAqt34eIiMTTt5c7bKybwd5Wijc5RQQZGMFnpE9LS4NEIkFwcHCtbVu1aoXJkyfD2dkZeXl5ePnll5GYmIjU1FT1NVe6Ym1tDQAoLi7WWC6XyyGVSnXaV1Wi4hL03gcRUUOyYOUWsUugBig2Ulbta4KHrqKiItjZ2Wl9J8nTp09RUlKC27dv4+WXX0bbtm31UpetrS0cHR2RkZEBD49nw9M5OTlQKBR1Ok1ZXzX9kIiISHvPH7TCOxbJ0Ah+erFnz564efMmDh06hPLycsjlchw/fhwAUF5ejvj4eNy9excAUFBQgKlTp8LJyQmurq56r00mkyEuLg43b96EQqFAZGQkAgIC4OTkpPe+iYhINyQSCQMXGSTBR7q6deuGzZs3Y+7cuQgLC4O1tTUmTpyovqbr6NGjiImJQUlJCWxtbeHn54fU1FQ0alS3UpcsWYIdO3bg8uXLWq8TFRWFBw8ewNvbG0+ePMHbb7+NpKSkOvVbXzy9SEREZPxqOnNllA+8TkxMREFBARYsWCB2KURERERaMbrQNXHiRKSnp+PJkyfo0qULDh06JHZJRERERLUyutBFREREZIwM7jFARERERKaIoYuIiIhIAAxdRERERAJg6CIiIiISAEMXERERkQAYuoiIiIgEwNBFREREJACGLiIiIiIBMHQRERERCYChi4iIiEgADF1EREREAmDoIiIiIhIAQxcRERGRABi6iIiIiATA0EVEREQkAIYuIiIiIgEwdBEREREJgKGLiIiISAAMXUREREQCYOgiIiIiEgBDFxEREZEAGLqIiIiIBMDQRURERCQAhi4iIiIiAfx/yCEIf0obqfgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 782.6x258.86 with 1 Axes>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "superdense.draw(output='mpl')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's now create, execute the quantum circuits, and plot the results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-29T01:25:56.845494Z",
     "start_time": "2018-09-29T01:25:56.640356Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAE6CAYAAAB00gm8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAZbElEQVR4nO3de5RdZZnn8e9jYSRZQkjKmqQqmjalLdZCuggJ0xIEwiWOouNScEm8NKAigyheEDTMOCq24FrxBqNNK7Q9KDpAg9pt26GBkLTQgEAuaDBO2tCYjCRBSSpKR2JCfOaPc4InJ3V5T6jLSc73s9ZZtfe73/3uZ/9Bfux7ZCaSJGlozxnrAiRJ2l8YmpIkFTI0JUkqZGhKklTI0JQkqZChKUlSoYPGuoCx1N7entOnTx/rMiRJTeShhx56IjM7+lvW0qE5ffp0lixZMtZlSJKayOTJk9cNtMzTs5IkFTI0JUkqZGhKklTI0JQkqZChKUlSIUNTkqRChqYkSYUMTUmSChmakiQVMjQlSSpkaEqSVMjQlCSpkKEpSVIhQ1OSpEKGpiRJhQxNSZIKGZqSJBUyNCVJKmRoSpJUyNCUJKmQoSlJUiFDU5KkQoamdAB6//vfz8te9jLmzJnT7/LMZMGCBcyaNYtXvepV/PjHP35m2Q033MDs2bOZPXs2N9xwwzPtDz30EMcddxyzZs1iwYIFZOaI74fUbAxN6QD0tre9jZtvvnnA5YsXL+aRRx5h2bJlfOlLX+IjH/kIAH19fSxcuJA77riDxYsXs3DhQrZu3QrAxRdfzJVXXsmyZct45JFHWLx48aj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1u2Uzg3OryScCLMvOx0a9Sak6GptSCImI8kJm5PSJid3tW/0GIiMupvMN55ljVKDWjUX1hu6TmkJlP7Q7LrPs/54iYAJwB/O+xqE1qZh5pSi0kIg4FnqwPyro+BwNnAjdUv1krqcrQlFpIRHwNeKD6W5eZv+2nz2GZuXXUi5P2A4am1CIi4q3At4HfAluAO4B/Bn4CbKiesh0P3Aj8j8x8eMyKlZqUoSm1iIi4FtgFLAROB84GXgKsARYBdwKHA1dl5rixqlNqZoam1AIi4iDgo8Chmbmgpv0I4D3Am4GDgcOAb2Tmu8ekUKnJGZpSi4iIScCUzPy/ETEO2Fl7Q1BEnAncABydmQ+NVZ1SM/ORE6lFZGYf0Fed3gEQEc+h8j/Pu4BDge0GpjQwQ1NqYZn5h5rZQ4BPjlUt0v7A07OSgMrnwoBddUEqqYahKUlSIb9yIklSIUNTkqRChqYkSYUMTUmSChmakiQVMjQlSSr0/wF1m50rgDXKggAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "backend = BasicAer.get_backend('qasm_simulator') # run on local simulator by default \n",
    "\n",
    "# Uncomment the following lines to run on a real device\n",
    "# IBMQ.load_accounts()\n",
    "# from qiskit.providers.ibmq import least_busy\n",
    "# backend = least_busy(IBMQ.backends(operational=True, simulator=False))\n",
    "# print(\"the best backend is \" + backend.name())\n",
    "\n",
    "superdense_job = execute(superdense, backend)\n",
    "superdense_result = superdense_job.result()\n",
    "\n",
    "plot_histogram(superdense_result.get_counts(superdense))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The state with the highest probability should match the message that Alice encoded earlier ($11$). Mathematically:\n",
    "- For a message of **00**: Bob received $|\\psi_{00}\\rangle = \\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle + |1_A 1_B\\rangle)$. Applying $CNOT$ gives: $\\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle + |1_A 0_B\\rangle)$. Applying $H$ on $q_A$ results in: $\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}[(|0_A\\rangle + |1_A\\rangle)|0_B\\rangle + (|0_A\\rangle - |1_A\\rangle)|0_B\\rangle] = |0_A 0_B\\rangle$ \n",
    "- For a message of **01**: Bob received $|\\psi_{01}\\rangle = \\frac{1}{\\sqrt{2}}(|1_A 0_B\\rangle + |0_A 1_B\\rangle)$. Applying $CNOT$ gives: $\\frac{1}{\\sqrt{2}}(|0_A 1_B\\rangle)+ |1_A 1_B\\rangle$. Applying $H$ on $q_A$ results in: $\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}[(|0_A\\rangle + |1_A\\rangle)|1_B\\rangle + (|0_A\\rangle - |1_A\\rangle)|1_B\\rangle + (|0_A\\rangle + |1_A\\rangle)|1_B\\rangle] = |0_A 1_B\\rangle$ \n",
    "- For a message of **10**: Bob received $|\\psi_{10}\\rangle = \\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle - |1_A 1_B\\rangle)$. Applying $CNOT$ gives: $\\frac{1}{\\sqrt{2}}(|0_A 0_B\\rangle - |1_A 0_B\\rangle)$. Applying $H$ on $q_A$ results in: $\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}[(|0_A\\rangle + |1_A\\rangle)|0_B\\rangle - (|0_A\\rangle - |1_A\\rangle)|0_B\\rangle] = |1_A 0_B\\rangle$ \n",
    "- For a message of **11**: Bob received $|\\psi_{11}\\rangle = \\frac{1}{\\sqrt{2}}(- |1_A 0_B\\rangle + |0_A 1_B\\rangle $. Applying $CNOT$ gives: $\\frac{1}{\\sqrt{2}}(|0_A 1_B\\rangle - |1_A 1_B\\rangle)$. Applying $H$ on $q_A$ results in: $\\frac{1}{\\sqrt{2}}\\frac{1}{\\sqrt{2}}[(|0_A\\rangle + |1_A\\rangle)|1_B\\rangle - (|0_A\\rangle - |1_A\\rangle)|1_B\\rangle] = |1_A 1_B\\rangle$ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
